package site.xuxingcan.wifihost;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferenceUtil {
    private static volatile SharedPreferenceUtil instance = null;

    public static SharedPreferenceUtil getInstance(Context mContext) {
        if (instance == null) {
            synchronized (SharedPreferenceUtil.class) {
                if (instance == null) {
                    instance = new SharedPreferenceUtil(mContext);
                }
            }
        }
        return instance;
    }

    private SharedPreferences mSharedPreferences;

    private SharedPreferenceUtil(Context mContext) {
        mSharedPreferences = mContext.getSharedPreferences("default", Context.MODE_PRIVATE);
    }

    public String getLineString() {
        return mSharedPreferences.getString("LineString", "无");
    }

    public void setLineStringh(String s) {
        mSharedPreferences.edit().putString("LineString", s).apply();
    }

    public String getQuanxianPath() {
        return mSharedPreferences.getString("QuanxianPath", "");
    }

    public void setQuanxianPath(String s) {
        mSharedPreferences.edit().putString("QuanxianPath", s).apply();
    }

    public String getRefreshPath() {
        return mSharedPreferences.getString("RefreshPath", "");
    }

    public void setRefreshPath(String s) {
        mSharedPreferences.edit().putString("RefreshPath", s).apply();
    }

    public long getLastClickTime() {
        return mSharedPreferences.getLong("LastClickTime", -1);
    }

    public void setLastClickTime(long s) {
        mSharedPreferences.edit().putLong("LastClickTime", s).apply();
    }

    public String getWifiName() {
        return mSharedPreferences.getString("WifiName", "wifi_ap");
    }

    public void setWifiName(String s) {
        mSharedPreferences.edit().putString("WifiName", s).apply();
    }

    public String getWifiKey() {
        return mSharedPreferences.getString("WifiKey", "1234567890");
    }

    public void setWifiKey(String s) {
        mSharedPreferences.edit().putString("WifiKey", s).apply();
    }

    public boolean getIsShowFirstDialog() {
        return mSharedPreferences.getBoolean("ShowFirstDialog", true);
    }

    public void setIsShowFirstDialog(boolean s) {
        mSharedPreferences.edit().putBoolean("ShowFirstDialog", s).apply();
    }

    public int getWifiButton() {
        return mSharedPreferences.getInt("WifiButton", 0);
    }

    public void setWifiButton(int s) {
        mSharedPreferences.edit().putInt("WifiButton", s).apply();
    }
}
